package com.gxa.controller.monthgoals;


import com.gxa.common.R;
import com.gxa.pojo.Monthly_Goals_Template;
import com.gxa.pojo.goalPojo.GoalPojo;
import com.gxa.service.EmpExcelWriteService;
import com.gxa.service.MonthGoalService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/template")
@Api(value = "模板编辑页面",tags = "模板编辑页面接口API")
public class EditTemplate {
    @Autowired
    private MonthGoalService monthGoalService;
    private EmpExcelWriteService empExcelWriteService;

    //添加
    @RequestMapping(value = "/insertTemplate",method = RequestMethod.POST)
    @ApiOperation(value = "添加月度目标接口",notes = "传递表头信息",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Goal_thead1",value = "目标1",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "Goal_thead2",value = "目标2",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "Goal_thead3",value = "目标3",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "Goal_thead4",value = "目标4",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "Goal_thead5",value = "目标5",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "Goal_thead6",value = "目标6",required = true,dataType = "String",paramType = "query"),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R editGoals(@RequestBody Monthly_Goals_Template monthly_goals_template){

        System.out.println("添加月度目标接口");
        System.out.println("添加月度目标接口");
        System.out.println("添加月度目标接口");
        System.out.println("添加月度目标接口");
        System.out.println(monthly_goals_template.toString());
        R r=monthGoalService.EditGoals(monthly_goals_template);

        return r;
    }

    //表头回显
    @RequestMapping(value = "/queryTemplate",method = RequestMethod.POST)
    @ApiOperation(value = "模板编辑页面回显",notes = "表头的信息",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R findGoals() throws IOException {

        System.out.println("模板编辑页面回显");
        System.out.println("模板编辑页面回显");
        System.out.println("模板编辑页面回显");
        System.out.println("模板编辑页面回显");
        R r=new R();
//        List<GoalPojo> list=new ArrayList<>();
//        GoalPojo goalPojo=new GoalPojo();
//        goalPojo.setGoal_Thead1("目标一");
//        goalPojo.setGoal_Thead2("目标二");
//        goalPojo.setGoal_Thead3("目标三");
//        goalPojo.setGoal_Thead4("目标四");
//        goalPojo.setGoal_Thead5("目标五");
//        goalPojo.setGoal_Thead6("目标六");
//        list.add(goalPojo);
//        monthGoalService.FindGoals();

//        empExcelWriteService.excelsWrite();
        return monthGoalService.FindGoals();
    }



}
